import type { Ref } from "vue";
import type { ITodo } from "../utils/todoStorage";

export default function useReomveTodo(todosRef: Ref<ITodo[]>) {
  const remove = (todo: ITodo) => {
    todosRef.value.splice(todosRef.value.indexOf(todo), 1);
  };

  const removeCompleted = () => {
    todosRef.value = todosRef.value.filter((v) => !v.completed);
  };

  return {
    remove,
    removeCompleted,
  };
}
